package com.chenguo.learn.demo.dao;

import com.chenguo.learn.demo.domain.entity.UserEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * @ClassName: UserDao
 * @Author: chenguo
 * @Data: 2018年10月16日 17时39分
 * @Description:
 * @Company: 成都灵奇空间软件
 * @Version: 1.0
 */

@Mapper
public interface UserDao {
    @Select(value = "select * from t_sys_user where id = #{id}")
    UserEntity getById(Integer id);

    @Insert(value = "insert into t_sys_user(id,user_name,real_name,password,sex,age,mobile) values(#{id},#{userName},#{realName},#{password},#{sex},#{age},#{mobile})")
    /*@SelectKey(statement = "SELECT nextval('seq_user_id')", keyProperty = "id", keyColumn = "id", resultType = Long.class, before = true)*/
    int save(UserEntity userEntity);

    @Update(value = "update t_sys_user set user_name=#{userName},real_name=#{realName},password=#{password},sex=#{sex},age=#{age},mobile=#{mobile} where id=#{id}")
    int update(UserEntity userEntity);

    @Delete("delete from t_sys_user where id=#{id}")
    int delete(UserEntity userEntity);
}
